package com.bdcom.autotest.interaction.http.callback;

import com.bdcom.autotest.interaction.bean.DeviceUpdBean;
import com.bdcom.autotest.interaction.http.IUpdateCallback;
import com.bdcom.autotest.interaction.step.StepThread;

import java.util.List;

public class UpdateCallBack implements IUpdateCallback {

    private StepThread mainrun;
    public UpdateCallBack(StepThread mainrun){
        this.mainrun = mainrun;
    }

    @Override
    public void updateCall( List<DeviceUpdBean> beans    ){
        for(DeviceUpdBean bean:beans){
            if(bean.getUdpFlag()){
                mainrun.addLog(bean.getMac()+"升级成功");
            }else{
                mainrun.addLog(bean.getMac() + "升级失败，原因:" + bean.getResultStr());
            }
        }
        mainrun.setUpgradeResult(beans);
    }

    @Override
    public void updateOneCall( DeviceUpdBean bean  ){
        if(bean.getUdpFlag()){
            mainrun.addLog(bean.getMac()+"升级成功");
        }else{
            mainrun.addLog(bean.getMac() + "升级失败，原因:" + bean.getResultStr());
        }
        List<DeviceUpdBean> upgradeResult = mainrun.getUpgradeResult();
        upgradeResult.add(bean);
    }
}
